import requestMeeting, { request } from '@/plugins/axios'
import { MeetingVideo, VideoEntity } from './interface'

/** 录播 */
export const fetchGetMeetingRecorders = async (meetingMoid: string) =>
	requestMeeting<VideoEntity>({
		url: `/mcc/${meetingMoid}/recorders`,
		method: 'get',
	}).then((res) => (res.success && res.data ? res.data : undefined))

/* 开始录像 */
export const fetchStartVideo = async (meetingMoid: string, params: MeetingVideo) =>
	request({
		url: `/mcc/${meetingMoid}/recorders`,
		method: 'post',
		data: params,
	}).then((res) => res)

/* 暂停,继续录像 */
export const fetchPauseContinueVideo = async (
	meetingMoid: string,
	rec_id: string,
	params: {
		state: 1 | 2
	}
) =>
	request({
		url: `/mcc/${meetingMoid}/recorders/${rec_id}/state`,
		method: 'put',
		data: params,
	}).then((res) => res)

export const fetchDeleteVideo = async (meetingMoid: string, rec_id: string, params: { recorder_mode: 1 | 2 | 3 }) =>
	request({
		url: `/mcc/${meetingMoid}/recorders/${rec_id}`,
		method: 'delete',
		data: params,
	}).then((res) => res)
